<?php
/**
 * Created by PhpStorm.
 * User: Digvijay
 * Date: 8/8/14
 * Time: 8:09 AM
 */

class Home extends MY_Home {

    public function index() {
        $cartDetails = $this->getCartDetails();
        $clientName = $this->isClientLoggedIn();
        $categories = $this->findAll("Category");
        $terms = $this->findContentByType(Contents::CONTENT_TERMS_AND_CONDITION);
        $systemConfig = $this->getSystemConfig(Systemconfig::SPECIAL_OFFER);
        $specialOffers = $this->findAll("Specialoffer");
        foreach ($categories as $category) {
            if ($category->getParent() == null) {
                $noOfSub = 0;
                foreach ($categories as $sub) {
                    if ($sub->getParent() != null && $sub->getParent()->getId() == $category->getId()) {
                        $noOfSub++;
                    }
                }
                $category->setNoOfSub($noOfSub);
            }
        }
        $data = array("categories" => $categories, "user" => $clientName, "cart" => $cartDetails, "terms" => $terms, "systemConfig" => $systemConfig, "offers" => $specialOffers);
        $this->load->view('index', $data);
    }

    public function order() {
        $emailData = array("client" => $this->findById("Agency", 1), "order" => $this->findById("Order", 1));
        $this->load->view('orderCancelEmail', $emailData);
    }

} 